Ext.define('vsg.security.StrategyHandler', {
    extend: 'Ext.util.Observable',
    alternateClassName: 'security.StrategyHandler',
    
	requires: [
		'vsg.security.ButtonPermission',
		'vsg.security.MenuItemPermission'
	],
	    
    
    constructor:function(config) {
		var me = this;

        Ext.applyIf(me, {
        	strategyMap:Ext.create("Ext.util.HashMap"),
        	userSecurityInfo:Ext.create("Ext.util.HashMap")
        	
        });
		
		// --- add xtype permission defined ---
		me.strategyMap.add("button" , Ext.create("vsg.security.ButtonPermission"));
		me.strategyMap.add("menuitem" , Ext.create("vsg.security.MenuItemPermission"));

        me.callParent(arguments);

		
	},
	
	setUserSecurity:function(userSecInfo) {
		var me = this;
		
		if (userSecInfo != null) {
			for (var i in userSecInfo) {
				me.userSecurityInfo.add(i , userSecInfo[i].permission);
			}
		}

	},
	
	/**
	 * parameter type is Ext.Component
	 */
	permittedHandle:function(component) {
		
		var me = this;
		
		var xtype = component.getXType();
		
		var permission = me.strategyMap.get(xtype);
		
		if (permission == null) {
			alert("Not Setting Permission for xtype : " + xtype);
		}
		
		var seccomp = component.seccomp;
		var seccompId = seccomp.id;
	
		var userSecPermission = me.userSecurityInfo.get( seccompId );

	
		var checkPermitted = permission.isPermitted(component , userSecPermission);
		
		
	}

});